<%--
 *  File:    DateCollateEdit.jsp
 *  @Author: jackwang	
 *  Date:    2013/7/4
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.PlanStdCollateEdit");
  String strModuleName = "IMG";
  String strTableName = "v_planstdcollate";
  String privilegeCode = "A01008";
  String contextPath = request.getContextPath();

%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@include file="/inc/Print.inc"%>
<html>
<head>
<title>PlanStdCollateEdit.jsp</title>
<PageFlow:CheckPageFlow pageName="p_planstdcollate"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/cn/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
	Vector searchresults = (Vector)pageContext.getAttribute("searchresults");
	if(searchresults == null) searchresults = new Vector();
	String  isfirst = (String) pageContext.getAttribute("isfirst");
%>
<script>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "PlanStdCollateEdit.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
function monthresult(){
    var numrows=document.cform.numrows.value;
    for(var i=0;i<numrows;i++){
      if(document.cform['standardtype'+i].value != document.cform['oldstandardtype'+i].value){
         document.cform['mdflag'+i].value=1;
      }
    }
	document.cform.actionname.value = "save";
  	document.cform.target = "_self";
  	isRunning = true;
  	document.cform.submit();
}
window.onload=function(){
          // cform.startdate.value=new Date().toFormatString("yyyy-mm-dd");
          // cform.enddate.value=new Date().toFormatString("yyyy-mm-dd");
}
function page_add()
{
	    if (!checkForm(cform)) return;
	    cform.actionname.value = "add";
	    cform.target = "_self";
	    isRunning = true;
	    cform.submit();
}
function page_delete()
  {
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
  }
</script>

</head>
 <%
  Calendar nowtime = Calendar.getInstance();
  int currentYear = nowtime.get(Calendar.YEAR);
  int currentMonth = nowtime.get(Calendar.MONTH) + 1;
  int currentQuarter=-1;
  if(currentMonth == 1 || currentMonth ==2 || currentMonth ==3){
	  currentQuarter=1;
  }
  else if(currentMonth == 4 || currentMonth ==5 || currentMonth ==6){
	  currentQuarter=2;
  }
  else if(currentMonth == 7 || currentMonth ==8 || currentMonth ==9){
	  currentQuarter=3;
  }
  else if(currentMonth == 10 || currentMonth ==11 || currentMonth ==12){
	  currentQuarter=4;
  }
 %>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_planstdcollate">
<input type="hidden" name="isfirst" value="N">
<input type="hidden" name="actionname">
 <input type="hidden" name="numrows" value="<%=searchresults.size() %>"/>
<table width="100%" cellspacing="0">
  <% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
</table>
	<table width="100%">
		 <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" 
                     height="36">  
         <tr onkeydown="if(event.keyCode==13) page_go();">
          <%
             java.util.Calendar cal = java.util.Calendar.getInstance();    
             String year = cal.get(Calendar.YEAR)+"";     
		     String month = String.valueOf(cal.get(Calendar.MONTH)+1);
		     if(cal.get(Calendar.MONTH) == 0){
				month = "12";
				year = (cal.get(Calendar.YEAR)-1)+"";
			 }  
		  %>
         <td width="8%" class="td_right"><%= label.getLabelName("L_Year1") + label.getLabelName("L_Colon") %></td>
         <td width="14%" class="td_center"><custom:selectdic property="zylyear" dictType="Years" label="L_Year1" defaultValueCost="" defaultValue="----"/></td>
         <td width="8%" class="td_right"><%= label.getLabelName("L_Quarter") + label.getLabelName("L_Colon") %></td>
         <td width="14%" class="td_center"><custom:selectdic property="zylquarter" dictType="Quarter" label="L_Quarter" defaultValueCost="" defaultValue="--"/></td>
         <td><a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
         <td width="*%" class="td_right">&nbsp;</td>
       </tr>
	</table>
	  <div style="overflow:auto;width:1000px">
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
          <tr class="deepblue-left">
            <td width="2%" class="title_center" >&nbsp;</td>
            <td width="10%" class="title_center"><%= label.getLabelName("L_Year") %></td>
            <td width="10%" class="title_center"><%= label.getLabelName("L_Quarter") %></td>
            <td width="10%" class="title_center"><%= label.getLabelName("L_Department") %><span class='red'>*</span></td>
            <td width="10%" class="title_center"><%= label.getLabelName("L_StandardMode") %></td>
            <!-- <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','userid')"><%= label.getLabelName("L_Operater") %></a></td> -->
            <td width="10%" class="title_center"><%= label.getLabelName("L_Datelastupdate") %></td>
          </tr>
          <%
             int j = 0;
             int s=1;
             String strClassType = new String();
             String strIsChecked = "";
             Integer defaultId = new Integer(-1);
             Integer flag = new Integer(-1);
             boolean bHasChecked = false;
             String Disabled="";
            
          %>
          <logic:iterate id="pageconfig" collection="<%= searchresults %>" indexId="seq">
          	<%
            HashMap pageConfig = (HashMap)pageContext.getAttribute("pageconfig");
            if(j%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "";
            }
            flag=(Integer)pageConfig.get("flag");
            if(flag.intValue()==1){
            	Disabled="disabled";
            }else{
            	Disabled="";
            }
           if(!bHasChecked)
            {
              strIsChecked = "Checked";
              defaultId = (Integer)pageConfig.get("planstdcollateid");
              bHasChecked = true;
              
            }else{
           		strIsChecked = "";
            }
             s= ((Integer)pageConfig.get("planstdcollateid")).intValue();
            j++;
          %>
          	<tr  class="none">
	            <td width="5%">
	              <input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( pageConfig.get("planstdcollateid") )%>" class="checkbox" <%=Disabled %>>
	            </td>
    	        <td><custom:write name="pageconfig" property="year" nbsp="true"/></td>
	            <td><custom:write name="pageconfig" property="quarter" nbsp="true"/></td>
	            <custom:hidden name="pageconfig" property="planstdcollateid" colIndex="<%=seq %>"/>
	            <custom:hidden name="pageconfig" property="standardtype" changedName="oldstandardtype" colIndex="<%=seq %>"/>
	            <td><custom:write name="pageconfig" property="deptname" nbsp="true"  /></td>
	            <td><custom:write name="pageconfig" property="standardtype" dictType="StandardMode"  nbsp="true" /></td>
	            <!--  <td><custom:selectdic name="pageconfig" property="standardtype" dictType="StandardMode" colIndex="<%=seq %>"/></td>-->
	            <td><custom:write name="pageconfig" property="datelastupdatedstr" nbsp="true" /></td>
	            <!-- <td><custom:write name="pageconfig" property="employeename" nbsp="true"/></td> -->
	         </tr>
	         <custom:hidden property="mdflag" colIndex="<%=seq %>" value="0"/>
          </logic:iterate>
           
           <tr class="none">
	           <td>&nbsp;</td>
		       <td><custom:selectdic name="newhash" property="year" dictType="Years" label="L_Year1"  value="<%=year %>"/></td>
		       <td><custom:selectdic name="newhash" property="quarter" dictType="Quarter" label="L_Quarter"  value="<%=String.valueOf(currentQuarter) %>"/></td>
	           <td><custom:select name="newhash" command="notnull" optionsName="alldeptnames" optionValueKey="deptid" optionInnerTextKey="deptname"	property="deptid"  defaultValue="----" defaultValueCost=" " label="L_Dept"/></td>
	           <td><custom:selectdic name="newhash"  property="standardtype" dictType="StandardMode"   label="L_StandardMode" defaultValueCost=" " defaultValue="------------" /></td>
	           <td>&nbsp;</td>
		     </tr>
    <% //--------------------------------------  flipping page --%>
    <%@ include file="/inc/SummaryAction.inc" %>
    <table width="100%">
        <tr> 
          <td class="summary_top"></td>
        </tr>
		<tr >
		  <td class="td_center">
		   <a onclick="page_add();"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
          <%if(searchresults.size() >0 ){%>
           <!-- <a onclick="monthresult()"><custom:button type="1" label="L_Save" imgsrc="new.gif" border="0" style="width:60"/></a> -->
           <a onclick="page_delete();"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
          <%}%>
          </td>
		</tr>
	</table>	
   </table>
   </div>
</form>
</table>


</body>
</html>


